package cn.jjxx.modules.sys.utils;

/**
 * @Title: BillRuleUtil.java .<br>
 * @Package cn.jjxx.modules.sys.utils .<br>
 * @Description: 单据规则相关规则类 .<br>
 * @author 郑成功 .<br>
 * @email a876459952@qq.com .<br>
 * @date 2018-8-9 下午3:45:21.<br>
 * @version V1.0.<br>
 */
public class BillRuleUtil {
	
	private static final int GDZ = 1;//固定值
	private static final int XTSJ = 2;//系统时间
	private static final int SXH = 3;//顺序号
	private static final int SJS = 4;//随机数
	private static final int ZDYSQL = 5;//自定义sql
	
	private static final int QBW = 1;//前补位
	private static final int HBW = 2;//后补位
	
	private static final String YYYY = "YYYY";//年
	private static final String YYYY_MM = "YYYY-MM";//年月
	private static final String YYYY_MM_DD = "YYYY-MM-DD";
	private static final String YYYYMM = "YYYYMM";
	private static final String YYYYMMDD = "YYYYMMDD";
	private static final String YYYYMMDDHHMISS = "YYYYMMDDHHMISS";
	
	private static final int GDCD = 1;//固定长度
	private static final int BGDCD = 2;//随机长度
	private static final int FWCD = 3;//范围长度

	/**
	 * @Title: BillRuleUtil.java .<br>
	 * @Package cn.jjxx.modules.sys.utils .<br>
	 * @Description: 单号规则类型 .<br>
	 * @author 郑成功 .<br>
	 * @email a876459952@qq.com .<br>
	 * @date 2018-8-9 下午3:43:58.<br>
	 * @version V1.0.<br>
	 */
	public enum RuleTypes{
		GDZ,XTSJ,SXH,SJS,ZDYSQL
	}
	
	/**
	 * @Title: BillRuleUtil.java .<br>
	 * @Package cn.jjxx.modules.sys.utils .<br>
	 * @Description: 补位方式 .<br>
	 * @author 郑成功 .<br>
	 * @email a876459952@qq.com .<br>
	 * @date 2018-8-9 下午3:44:41.<br>
	 * @version V1.0.<br>
	 */
	public enum CoverTypes{
		QBW,HBW
	}
	
	/**
	 * @Title: BillRuleUtil.java .<br>
	 * @Package cn.jjxx.modules.sys.utils .<br>
	 * @Description: 系统时间格式 .<br>
	 * @author 郑成功 .<br>
	 * @email a876459952@qq.com .<br>
	 * @date 2018-8-9 下午3:44:10.<br>
	 * @version V1.0.<br>
	 */
	public enum DateFormats{
		YYYY,YYYY_MM,YYYY_MM_DD,YYYYMM,YYYYMMDD,YYYYMMDDHHMISS
	}
	
	/**
	 * @Title: BillRuleUtil.java .<br>
	 * @Package cn.jjxx.modules.sys.utils .<br>
	 * @Description: 随机数类型 .<br>
	 * @author 郑成功 .<br>
	 * @email a876459952@qq.com .<br>
	 * @date 2018-8-9 下午3:44:58.<br>
	 * @version V1.0.<br>
	 */
	public enum RandomTypes{
		GDCD,BGDCD,FWCD
	}
	
	/**
	 * @Description: 传入值返回规则枚举类型 .<br>
	 * @param rule 规则.<br>
	 * @author 郑成功 .<br>
	 * @date 2018-8-9 下午4:17:19.<br>
	 */
	public static RuleTypes ruleType(int rule){
		RuleTypes returnValue = RuleTypes.GDZ;
		switch (rule) {
			case GDZ:
				returnValue = RuleTypes.GDZ;
				break;
			case XTSJ:
				returnValue = RuleTypes.XTSJ;
				break;
			case SXH:
				returnValue = RuleTypes.SXH;
				break;
			case SJS:
				returnValue = RuleTypes.SJS;
				break;
			case ZDYSQL:
				returnValue = RuleTypes.ZDYSQL;
				break;
		}
		return returnValue;
	}
	
	/**
	 * @Description: 传入值返回补位枚举类型 .<br>
	 * @param type 类型.<br>
	 * @author 郑成功 .<br>
	 * @date 2018-8-9 下午4:16:46.<br>
	 */
	public static CoverTypes coverType(int type){
		CoverTypes ct = CoverTypes.QBW;
		switch (type) {
		case QBW:
			ct = CoverTypes.QBW;
			break;
		case HBW:
			ct = CoverTypes.HBW;
			break;
		}
		return ct;
	} 
	
	/**
	 * @Description: 获取日期格式值 .<br>
	 * @param format 格式化.<br>
	 * @return 返回日期格式化枚举类型值.<br>   
	 * @author 郑成功 .<br>
	 * @date 2018-8-9 下午4:26:18.<br>
	 */
	public static DateFormats dateFormat(String format){
		DateFormats df = DateFormats.YYYYMMDD;
		switch (format) {
			case YYYY:
				df = DateFormats.YYYY;
				break;
			case YYYY_MM:
				df = DateFormats.YYYY_MM;
				break;
			case YYYY_MM_DD:
				df = DateFormats.YYYY_MM_DD;
				break;
			case YYYYMM:
				df = DateFormats.YYYYMM;
				break;
			case YYYYMMDD:
				df = DateFormats.YYYYMMDD;
				break;
			case YYYYMMDDHHMISS:
				df = DateFormats.YYYYMMDDHHMISS;
				break;
		}
		return df;
	}
	
	/**
	 * @Description: 获取随机类型值 .<br>
	 * @param type 类型.<br>   
	 * @return 返回随机类型枚举值.<br>   
	 * @author 郑成功 .<br>
	 * @date 2018-8-9 下午4:25:48.<br>
	 */
	public static RandomTypes randomType(int type){
		RandomTypes rt = RandomTypes.GDCD;
		switch (type) {
			case GDCD:
				rt = RandomTypes.GDCD;
				break;
			case BGDCD:
				rt = RandomTypes.BGDCD;
				break;
			case FWCD:
				rt = RandomTypes.FWCD;
				break;
		}
		return rt;
	}
	
	public static void main(String[] args) {
		System.err.println(ruleType(SXH));
		System.err.println(coverType(HBW));
		System.err.println(dateFormat(YYYY_MM));
		System.err.println(randomType(BGDCD));
	}
	
}
